package com.lijinquan.tank.abstractfactory;

import com.lijinquan.tank.Audio;
import com.lijinquan.tank.ResourceMgr;
import com.lijinquan.tank.TankFrame;

import java.awt.*;

/**
 * Created by lijinquan on 2020/8/22.
 */
public class RectExplode extends BaseExplode {
    private int x, y;

    private boolean living = true;

    TankFrame tankFrame = null;
    private int step = 0;

    public static final int WIDTH = ResourceMgr.explodes[0].getWidth(), HEIGHT = ResourceMgr.explodes[0].getHeight();

    public RectExplode(int x, int y, TankFrame tankFrame) {
        this.x = x;
        this.y = y;
        this.tankFrame = tankFrame;
        new Thread(() ->
                new Audio("audio/explode.wav").play()
        ).start();
    }

    public void paint(Graphics g) {


        Color color = g.getColor();
        g.setColor(Color.blue);
        g.fillRect(x,y,10*step,10*step);
        step++;
        if (step >= ResourceMgr.explodes.length)
            tankFrame.explodes.remove(this);

        g.setColor(color);
    }
}
